<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

$api = app('Dingo\Api\Routing\Router');
//支付回调
$api->version('v1',[
    'namespace' => 'App\Api\Controllers',
    'middleware' => ['serializer:array', 'bindings']
], function ($api) {
    $api->post('notify', 'PayController@notify')
        ->name('api.pay.notify');
    $api->post('conversion', 'ConversionsController@store')
        ->name('api.conversion.store');
    // 短信验证码
    $api->post('verificationCodes', 'VerificationCodesController@store')
        ->name('api.verificationCodes.store');
    // 用户注册
    $api->post('user', 'UsersController@store')
        ->name('api.user.store');
    // 找回密码
    $api->post('user/retrieve_password', 'UsersController@retrieve_password')
        ->name('api.user.retrieve_password');
    // 邀请好友
    $api->post('invite', 'UsersController@invite')
        ->name('api.user.invite');
    // 登录
    $api->post('authorizations', 'AuthorizationsController@store')
        ->name('api.authorizations.store');
    // 刷新token
    $api->put('authorizations/current', 'AuthorizationsController@update')
        ->name('api.authorizations.update');
    // 删除token
    $api->delete('authorizations/current', 'AuthorizationsController@destroy')
        ->name('api.authorizations.destroy');
    //banner列表
    $api->get('banner', 'BannersController@index')
        ->name('api.banner.index');
    //banner详情
    $api->get('banner/{banner}', 'BannersController@show')
        ->name('api.banner.show');
    //公告列表
    $api->get('notice', 'NoticesController@index')
        ->name('api.notice.index');
    //公告详情
    $api->get('notice/{notice}', 'NoticesController@show')
        ->name('api.notice.show');


    $api->post('index', 'ForumController@index')
        ->name('api.forum.index');


    //矿机列表
    $api->get('machines', 'MachinesController@index')
        ->name('api.notice.index');
    //矿机详情
    $api->get('machines/{machines}', 'MachinesController@show')
        ->name('api.notice.show');
    //币世界咨询
    $api->get('new', 'NewsController@index')
        ->name('api.new.index');
    //咨询详情
    $api->get('new/{new}', 'NewsController@show')
        ->name('api.new.show');
    //配置
    $api->get('set', 'SetController@index')
        ->name('api.set.index');
    //计算器
    $api->get('counter', 'SetController@counter')
        ->name('api.set.counter');
    //上传图片
    $api->post('upload', 'uploadController@store')
        ->name('api.upload.store');
    //qq号
    $api->get('customer', 'CustomerController@index')
        ->name('api.customer.index');
    //社区我的主页

    // 需要 token 验证的接口
    $api->group(['middleware' => 'api.auth'], function($api) {

        // 当前登录用户信息
        $api->get('user', 'UsersController@me')
            ->name('api.user.show');
        // 编辑登录用户信息
        $api->patch('user', 'UsersController@update')
            ->name('api.user.update');
        //充值接口
        $api->post('recharge', 'RechargesController@store')
            ->name('api.recharge.store');
        //充值接口
        $api->get('recharge', 'RechargesController@index')
            ->name('api.recharge.index');
        //提现接口
        $api->post('withdraw', 'WithdrawsController@store')
            ->name('api.withdraw.store');
        //提现列表接口
        $api->get('withdraw', 'WithdrawsController@index')
            ->name('api.withdraw.index');
        //转换列表接口
        $api->get('conversion', 'ConversionsController@index')
            ->name('api.conversion.index');
        //转换接口
        //提币列表接口
        $api->get('coin', 'CoinsController@index')
            ->name('api.coin.index');
        //提币接口
        $api->post('coin', 'CoinsController@store')
            ->name('api.coin.store');
        //获取用户团队列表
        $api->get('team', 'UsersController@team')
            ->name('api.user.team');
        //获取财务明细
        $api->get('user_log', 'UsersController@user_log')
            ->name('api.user.user_log');
        //绑定比特币地址
        $api->post('bind_btc_address', 'UsersController@bind_btc_address')
            ->name('api.user.bind_btc_address');
        //订单列表接口
        $api->get('order', 'OrdersController@index')
            ->name('api.order.index');
        //购买接口
        $api->post('order', 'OrdersController@store')
            ->name('api.order.store');
        //交电费
        $api->post('electricity_fee', 'ElectricityFeeController@store')
            ->name('api.electricity_fee.store');
        //实名认证
        $api->post('real_verified', 'UsersController@real_verified')
            ->name('api.user.real_verified');
        //二维码
        $api->get('qrcode', 'UsersController@qrcode')
            ->name('api.user.qrcode');
        //添加地址
        $api->post('address', 'AddressController@store');
        //地址列表
        $api->get('address', 'AddressController@index');

        //关注
        $api->post('follow', 'ForumController@follow')
            ->name('api.forum.follow');
        //取消关注
        $api->post('cancel', 'ForumController@cancel')
            ->name('api.forum.cancel');

        $api->post('homepage', 'ForumController@homepage')
            ->name('api.forum.homepage');
        //社区我的关注
        $api->get('dynamic', 'ForumController@dynamic')
            ->name('api.forum.dynamic');
        //社区推荐
        $api->get('recommend', 'ForumController@recommend')
            ->name('api.forum.recommend');
        //写问答 文章
        $api->post('store', 'ForumController@store')
            ->name('api.forum.store');
        //评论
        $api->post('comment', 'ForumController@comment')
            ->name('api.forum.comment');
        //我的股权列表
        $api->post('stockorder', 'StockOrderController@ksList')
            ->name('api.StockOrder.ksList');
        //股权列表
        $api->get('stockstrades', 'StocksTradesController@index')
            ->name('api.stockstrades.index');
           //交易中心出售
        $api->post('sell', 'StocksTradesController@Sell')
            ->name('api.stockstrades.Sell');
        //购买
        $api->get('purchase', 'StocksTradesController@purchase')
            ->name('api.stockstrades.purchase');

        //股权首页
        $api->get('profit', 'StocksController@profit')
            ->name('api.stocks.profit');

        // 股权展示
        $api->get('stocks', 'StocksController@index')
            ->name('api.stocks.index');
        //购买
        $api->get('equity', 'StocksController@purchase')
            ->name('api.stocks.purchase');

        //用户搜索
        $api->post('search', 'UsersController@search');
        //用户附近搜索
        $api->post('search_round', 'UsersController@search_round');
        //添加购物车
        $api->post('cars', 'CarsController@store');
        //购物车列表
        $api->get('cars', 'CarsController@list');
        //投诉建议
        $api->post('suggestion', 'suggestionController@store');

    });
});